/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.ac.iie.di.wx.server.timerTask;

import cn.ac.iie.di.wx.server.common.RuntimeEnv;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimerTask;
import org.apache.log4j.Logger;

/**
 *
 * @author Administrator
 */
public class CountTask extends TimerTask {

    static Logger logger = Logger.getLogger(CountTask.class.getName());
    private int cout = 0;

    public CountTask() {
    }

    @Override
    public void run() {
        Date date = new Date();
        SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss");//设置日期格式
        String dfDate = df.format(date);
        if (dfDate.equals("23:59:59")) {
            logger.info("addUnicontrol: " + RuntimeEnv.addUNCTCount.get()
                    + "\t" + "delUnicontrol: " + RuntimeEnv.delUNCTCount.get()
                    + "\t" + "addUserFriendCircle: " + RuntimeEnv.addUFCMCount.get()
                    + "\t" + "delUserFriendCircle: " + RuntimeEnv.delUFCMCount.get());
            logger.info("init cout value");
            logger.info("OCR: " + RuntimeEnv.OCRCount.get()
                    + "\t" + "queryfriendcirlebykey: " + RuntimeEnv.FCMBKCount.get()
                    + "\t" + "queryfriendcircle: " + RuntimeEnv.FCMCount.get()
                    + "\t" + "querypicturebypic: " + RuntimeEnv.PBPCount.get());
            logger.info("ORC_OCR: " + RuntimeEnv.ORC_OCRCount.get()
                    + "\t" + "ORC_PBP: " + RuntimeEnv.ORC_PBPCount.get());
            logger.info("init cout value");
            RuntimeEnv.OCRCount.set(0);
            RuntimeEnv.FCMBKCount.set(0);
            RuntimeEnv.FCMCount.set(0);
            RuntimeEnv.PBPCount.set(0);
            RuntimeEnv.addUNCTCount.set(0);
            RuntimeEnv.delUNCTCount.set(0);
            RuntimeEnv.addUFCMCount.set(0);
            RuntimeEnv.delUFCMCount.set(0);
            RuntimeEnv.ORC_OCRCount.set(0);
            RuntimeEnv.ORC_PBPCount.set(0);
        }
        //设置时间间隔
        int per = 59;
        if (cout < per) {
            ++cout;
        } else {
            logger.info("addUnicontrol: " + RuntimeEnv.addUNCTCount.get()
                    + "\t" + "delUnicontrol: " + RuntimeEnv.delUNCTCount.get()
                    + "\t" + "addUserFriendCircle: " + RuntimeEnv.addUFCMCount.get()
                    + "\t" + "delUserFriendCircle: " + RuntimeEnv.delUFCMCount.get());
            logger.info("OCR: " + RuntimeEnv.OCRCount.get()
                    + "\t" + "queryfriendcirlebykey: " + RuntimeEnv.FCMBKCount.get()
                    + "\t" + "queryfriendcircle: " + RuntimeEnv.FCMCount.get()
                    + "\t" + "querypicturebypic: " + RuntimeEnv.PBPCount.get());
            logger.info("ORC_OCR: " + RuntimeEnv.ORC_OCRCount.get()
                    + "\t" + "ORC_PBP: " + RuntimeEnv.ORC_PBPCount.get());
            cout = 0;

        }

    }

}
